package com.manlitech.cloudboot.clickhouse.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.manlitech.cloudboot.clickhouse.mapper.UserInfoMapper;
import com.manlitech.cloudboot.clickhouse.pojo.UserInfo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.manlitech.cloudboot.common.utils.Result;
import com.manlitech.cloudboot.common.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shensg
 * @date 2021/7/23 14:03
 */
@Service
@DS("ds_clickhouse")
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService {

    @Autowired
    UserInfoMapper userInfoMapper;

    @Override
    public void saveData(UserInfo userInfo) {
        userInfoMapper.saveData(userInfo);
    }

    @Override
    public UserInfo selectById(Integer id) {
        return userInfoMapper.selectById(id);
    }

    @Override
    public List<UserInfo> selectList() {
        return userInfoMapper.selectList();
    }

    @Override
    public Result selectListByPage() {
        IPage<UserInfo> testPage = new Page<>(1, 2);
        testPage = this.lambdaQuery().page(testPage);
        return ResultUtil.success(testPage);
    }
}
